package com.cyan.learn.pattern.command;

import java.util.Map;

/**
 * 订单命令实现
 */
public class OrderCommand implements Command {

    // 持有接收者
    private SeniorChef seniorChef;

    // 调用者
    private Order order;

    public OrderCommand(SeniorChef seniorChef, Order order) {
        this.seniorChef = seniorChef;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "桌订单开始准备-----------");

        Map<String, Integer> foodDir = order.getFoodDir();
        for (Map.Entry<String, Integer> entry : foodDir.entrySet()) {
            String food = entry.getKey();
            Integer num = entry.getValue();
            seniorChef.makeFood(food, num);
        }

        System.out.println(order.getDiningTable() + "桌订单准备好了-----------");

    }
}
